package com.company.test30.CharSoftware;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * Created by v on 16-12-6.
 */
public class ReceptionMessage implements Runnable {
    private ChatPanel chatPanel;
    private DataInputStream input;

    public ReceptionMessage(ChatPanel chatPanel,DataInputStream input){
        this.chatPanel=chatPanel;
        this.input=input;
    }

    @Override
    public void run() {
        try{
            while (true){
                String message=input.readUTF();
                synchronized (chatPanel){
                    chatPanel.jtaShow.append(message);
                }
            }
        }catch (IOException ex){
            ex.printStackTrace();
        }
    }
}
